#include <iostream>

using namespace std;

// 基类
class Base
{
public:
    Base() {}
    virtual ~Base(){}

    virtual void print() { cout << "Base::print()" << endl; }
};

class A : public Base
{
public:
    A() {}
    virtual ~A(){}

    virtual void print() { cout << "A::print()" << endl; }
};

class B : public Base
{
public:
    B() {}
    virtual ~B(){}

    virtual void print() { cout << "B::print()" << endl; }
};

int main()
{
    Base *a = new A;
    Base *b = new B;

    a->print();
    b->print();

    delete a;
    a = nullptr;
    delete b;
    b = nullptr;

    return 0;
}